//
//  NSPredicate+Extension.m
//  GameSDK
//
//  Created by Johnny on 2017/7/31.
//  Copyright © 2017年 Johnny. All rights reserved.
//

#import "NSPredicate+Extension.h"

@implementation NSPredicate (Extension)
- (BOOL)evaluateValue:(NSString *)value withRegex:(NSString *)regex {
    NSPredicate * regularPred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
    
    return [regularPred evaluateWithObject:value];
}

- (BOOL)evaluateEmail:(NSString *)email {
    return [self evaluateValue:email withRegex:@"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"];
}

- (BOOL)evaluateMobile:(NSString *)mobile {
    return [self evaluateValue:mobile withRegex:@"^1[0|1|2|3|4|5|6|7|8|9][0-9]\\d{8}$"];
}



@end
